package com.sunwayworld.basemodule.common.eptstorage.file.excelread.service.impl;

import com.sunwayworld.basemodule.common.eptstorage.file.excelread.bean.LimsSheetTitleConfigBean;
import com.sunwayworld.basemodule.common.eptstorage.file.excelread.dao.LimsSheetTitleConfigDao;
import com.sunwayworld.basemodule.common.eptstorage.file.excelread.service.LimsSheetTitleConfigService;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@GikamBean
public class LimsSheetTitleConfigServiceImpl implements LimsSheetTitleConfigService {

    @Autowired
    private LimsSheetTitleConfigDao limsSheetTitleConfigDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsSheetTitleConfigDao getDao() {
        return limsSheetTitleConfigDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsSheetTitleConfigBean limsSheetTitleConfig = jsonWrapper.parseUnique(LimsSheetTitleConfigBean.class);
        limsSheetTitleConfig.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsSheetTitleConfig);
        return limsSheetTitleConfig.getId();
    }

}
